home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / artemis / artsrc1 / plt16asm.asm < prev    next >
Assembly Source File  |  1994-06-01  |  47KB  |  890 lines

  1. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 1
  2.  
  3. Copyright (C) 1983-90 MetaWare Incorporated.  Serial 1-999999.
  4. Target: Intel 80386/486
  5. Scanner C_lexicon(18-Jan-90 18:27:04)
  6. Parser  C_phrase_structure(07-Nov-90 09:25:08)
  7. =====>  Profile j:\c\inc/hc.pro included in this compilation.
  8. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 2
  9.  
  10. Addr  Object                    Source Program and Assembly Listing
  11.                                     extrn    _egbwork,scrmode,debugmsg,EGB_getPalette
  12.                                     extrn    EGB_palette,sprintf,msgout,calloc
  13.                                 plt16    segment 'CODE'
  14. 0000                                mod4   0
  15.                                 ;/*
  16.                                 ;    ARTemis (Graphic Editor for FM-TOWNS)
  17.                                 ;    (c) MATSUUCHI Ryosuke 1992
  18.                                 ;    plt16.c
  19.                                 ;    このモジュールは、16色モードにおいてパレットどうしの混色や
  20.                                 ;    近似パレット検索を行うときの処理のためのものです。
  21.                                 ;*/
  22.                                 ;#include <stdio.h>
  23.                                 ;#include <malloc.h>
  24.                                 ;#include <egb.h>
  25.                                 ;#include "ge.h"
  26.                                 ;#include "plt.h"
  27.                                 ;//     (local) 指定したパレット番号のパレットを得る
  28.                                 ;//-----------------------------------------------------------------------
  29.                                 ;static _GRB _getplt(int plt)
  30. 0000                            .L0000:
  31.                                 _getplt    proc   near
  32. 0000  55                            push   ebp
  33. 0001  8b ec                         mov    ebp,esp
  34. 0003  81 ec 00000084                sub    esp,132
  35. 0009  57                            push   edi
  36.                                 ;{
  37. 000a  8b 7d 08                      mov    edi,8[ebp]
  38.                                 ;    unsigned char pal_[4+8*16];
  39.                                 ;    EGB_getPalette(1,(char *)pal_);
  40. 000d  8d 85 ffffff7c                lea    eax,-132[ebp]
  41. 0013  50                            push   eax
  42. 0014  6a 01                         push   1
  43. 0016  e8 --------e                  call   EGB_getPalette
  44.                                 ;    return    (int)((pal_[4+8*plt+4+2]>>4)&15)*256 +
  45. 001b  0f b6 44 fd 86                movzbl eax,-122[ebp+edi*8]
  46. 0020  c1 f8 04                      sar    eax,4
  47. 0023  25 0000000f                   and    eax,15
  48. 0028  c1 e0 08                      shl    eax,8
  49. 002b  0f b6 54 fd 85                movzbl edx,-123[ebp+edi*8]
  50. 0030  c1 fa 04                      sar    edx,4
  51. 0033  81 e2 0000000f                and    edx,15
  52. 0039  c1 e2 04                      shl    edx,4
  53. 003c  03 d0                         add    edx,eax
  54. 003e  0f b6 44 fd 84                movzbl eax,-124[ebp+edi*8]
  55. 0043  c1 f8 04                      sar    eax,4
  56. 0046  25 0000000f                   and    eax,15
  57. 004b  03 c2                         add    eax,edx
  58. 004d  83 c4 08                      add    esp,8
  59.                                 ;            (int)((pal_[4+8*plt+4+1]>>4)&15)* 16 +
  60.                                 ;            (int)((pal_[4+8*plt+4  ]>>4)&15);
  61.                                 ;}
  62. 0050  5f                            pop    edi
  63. 0051  c9                            leave
  64. 0052  c3                            rets
  65.                                 _getplt    endp
  66. 0053  90                            mod4   0
  67.                                 ;//     (local) 指定したパレット番号のパレットを設定する
  68. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 3
  69.  
  70. Addr  Object                    Source Program and Assembly Listing
  71.                                 ;//-----------------------------------------------------------------------
  72.                                 ;static void _setplt(int plt, _GRB grb)
  73. 0054                            .L0054:
  74.                                 _setplt    proc   near
  75. 0054  55                            push   ebp
  76. 0055  8b ec                         mov    ebp,esp
  77. 0057  81 ec 00000084                sub    esp,132
  78. 005d  57                            push   edi
  79.                                 ;{
  80. 005e  8b 7d 0c                      mov    edi,12[ebp]
  81.                                 ;    char pal_[4+8*16];
  82.                                 ;    DWORD(pal_ + 0) = 1;
  83. 0061  c7 85 ffffff7c 00000001       mov    dword ptr -132[ebp],1
  84.                                 ;    DWORD(pal_ + 4) = plt;
  85. 006b  8b 45 08                      mov    eax,8[ebp]
  86. 006e  89 45 80                      mov    -128[ebp],eax
  87.                                 ;    BYTE (pal_ + 8) = (grb&15) << 4;
  88. 0071  8b c7                         mov    eax,edi
  89. 0073  25 0000000f                   and    eax,15
  90. 0078  c0 e0 04                      shl    al,4
  91. 007b  88 45 84                      mov    -124[ebp],al
  92.                                 ;    BYTE (pal_ + 9) = ((grb>>4)&15)<<4;
  93. 007e  8b c7                         mov    eax,edi
  94. 0080  c1 f8 04                      sar    eax,4
  95. 0083  25 0000000f                   and    eax,15
  96. 0088  c0 e0 04                      shl    al,4
  97. 008b  88 45 85                      mov    -123[ebp],al
  98.                                 ;    BYTE (pal_ +10) = ((grb>>8)&15)<<4;
  99. 008e  8b c7                         mov    eax,edi
  100. 0090  c1 f8 08                      sar    eax,8
  101. 0093  25 0000000f                   and    eax,15
  102. 0098  c0 e0 04                      shl    al,4
  103. 009b  88 45 86                      mov    -122[ebp],al
  104.                                 ;    BYTE (pal_ +11) = 0;
  105. 009e  2b c0                         sub    eax,eax
  106. 00a0  88 45 87                      mov    -121[ebp],al
  107.                                 ;    EGB_palette(_egbwork,0,pal_);
  108. 00a3  8d 95 ffffff7c                lea    edx,-132[ebp]
  109. 00a9  52                            push   edx
  110. 00aa  50                            push   eax
  111. 00ab  68 00000000e                  push   offset _egbwork
  112. 00b0  e8 --------e                  call   EGB_palette
  113. 00b5  83 c4 0c                      add    esp,12
  114.                                 ;}
  115. 00b8  5f                            pop    edi
  116. 00b9  c9                            leave
  117. 00ba  c3                            rets
  118.                                 _setplt    endp
  119. 00bb  90                            mod4   0
  120.                                 ;//     (local) _GRB カラーどうしの「相違度(difference)」を計算する
  121.                                 ;//-----------------------------------------------------------------------
  122.                                 ;static int _coldiff(_GRB grb1, _GRB grb2)
  123. 00bc                            .L00bc:
  124.                                 _coldiff    proc   near
  125. 00bc  55                            push   ebp
  126. 00bd  8b ec                         mov    ebp,esp
  127. 00bf  56                            push   esi
  128. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 4
  129.  
  130. Addr  Object                    Source Program and Assembly Listing
  131. 00c0  57                            push   edi
  132.                                 ;{
  133. 00c1  8b 7d 08                      mov    edi,8[ebp]
  134.                                 ;    int t,r;
  135.                                 ;    r = 0;
  136. 00c4  2b c9                         sub    ecx,ecx
  137.                                 ;    t = (int)((grb1>>8)&15)-(int)((grb2>>8)&15);
  138. 00c6  8b 45 0c                      mov    eax,12[ebp]
  139. 00c9  c1 f8 08                      sar    eax,8
  140. 00cc  25 0000000f                   and    eax,15
  141. 00d1  8b f7                         mov    esi,edi
  142. 00d3  c1 fe 08                      sar    esi,8
  143. 00d6  81 e6 0000000f                and    esi,15
  144. 00dc  2b f0                         sub    esi,eax
  145.                                 ;    r += t*t;
  146. 00de  8b c6                         mov    eax,esi
  147. 00e0  f7 e0                         mul    eax
  148. 00e2  03 c8                         add    ecx,eax
  149.                                 ;    t = (int)((grb1>>4)&15)-(int)((grb2>>4)&15);
  150. 00e4  8b 45 0c                      mov    eax,12[ebp]
  151. 00e7  c1 f8 04                      sar    eax,4
  152. 00ea  25 0000000f                   and    eax,15
  153. 00ef  8b f7                         mov    esi,edi
  154. 00f1  c1 fe 04                      sar    esi,4
  155. 00f4  81 e6 0000000f                and    esi,15
  156. 00fa  2b f0                         sub    esi,eax
  157.                                 ;    r += t*t;
  158. 00fc  8b c6                         mov    eax,esi
  159. 00fe  f7 e0                         mul    eax
  160. 0100  03 c8                         add    ecx,eax
  161.                                 ;    t = (int)(grb1&15)-(int)(grb2&15);
  162. 0102  8b 45 0c                      mov    eax,12[ebp]
  163. 0105  25 0000000f                   and    eax,15
  164. 010a  8b f7                         mov    esi,edi
  165. 010c  81 e6 0000000f                and    esi,15
  166. 0112  2b f0                         sub    esi,eax
  167.                                 ;    r += t*t;
  168. 0114  8b c6                         mov    eax,esi
  169. 0116  f7 e0                         mul    eax
  170. 0118  03 c8                         add    ecx,eax
  171.                                 ;    return r;
  172. 011a  8b c1                         mov    eax,ecx
  173.                                 ;}
  174. 011c  5f                            pop    edi
  175. 011d  5e                            pop    esi
  176. 011e  c9                            leave
  177. 011f  c3                            rets
  178.                                 _coldiff    endp
  179. 0120                                mod4   0
  180.                                 ;//     (local) 近似パレットリストのための型定義・変数定義
  181.                                 ;//-----------------------------------------------------------------------
  182.                                 ;typedef struct _nearplt_e {        // 近似パレットリストの1要素(NEARPLTの補助)
  183.                                 ;    struct _nearplt_e *next;
  184.                                 ;    bool    used;
  185.                                 ;    char    plt;
  186.                                 ;    int        dist;
  187.                                 ;} NEARPLTe;
  188. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 5
  189.  
  190. Addr  Object                    Source Program and Assembly Listing
  191.                                 ;typedef    struct {                // ある _GRB カラーに対する近似パレットリスト
  192.                                 ;    NEARPLTe    *neartop;
  193.                                 ;    NEARPLTe    near[16];
  194.                                 ;} NEARPLT;
  195.                                 ;static    NEARPLT    *nearplt;    // 全 _GRB カラーに対する近似パレットリスト
  196.                                 ;static    _GRB    pltgrb[16];    // 各パレットの現在の設定状態
  197.                                 ;//     (local) 近似パレットリストへの要素の挿入
  198.                                 ;//-----------------------------------------------------------------------
  199.                                 ;static void NEARPLT_ins(_GRB grb, int plt)
  200. 0120                            .L0120:
  201.                                 NEARPLT_ins    proc   near
  202. 0120  55                            push   ebp
  203. 0121  8b ec                         mov    ebp,esp
  204. 0123  83 ec 10                      sub    esp,16
  205. 0126  53                            push   ebx
  206. 0127  56                            push   esi
  207. 0128  57                            push   edi
  208.                                 ;// [_GRBカラー grb に対する近似パレットリストに、plt 番のパレットを挿入する]
  209.                                 ;//        この関数は、_GRBカラー grb に対する近似パレットリストに plt 番の
  210.                                 ;//        パレットがまだ登録されていない状態で呼ばなくてはいけない。
  211.                                 ;{
  212.                                 ;    NEARPLT *nplt;
  213.                                 ;    int dist;
  214.                                 ;    nplt = nearplt + grb;
  215. 0129  8b 45 08                      mov    eax,8[ebp]
  216. 012c  8d 04 85 00000000             lea    eax,[eax*4]
  217. 0133  8d 14 80                      lea    edx,[eax+eax*4]
  218. 0136  8d 14 d0                      lea    edx,[eax+edx*8]
  219. 0139  03 15 00000000r               add    edx,@plt16
  220. 013f  89 55 fc                      mov    -4[ebp],edx
  221.                                 ;    dist = _coldiff(grb, pltgrb[plt]);
  222. 0142  8b 45 0c                      mov    eax,12[ebp]
  223. 0145  ff 34 85 00000004r            push   dword ptr @plt16+4[eax*4]
  224. 014c  ff 75 08                      push   dword ptr 8[ebp]
  225. 014f  8b da                         mov    ebx,edx
  226. 0151  e8 ffffff66                   call   00bc
  227. 0156  89 45 f8                      mov    -8[ebp],eax
  228. 0159  83 c4 08                      add    esp,8
  229.                                 ;    if (nplt->neartop == NULL) {
  230. 015c  83 3b 00                      cmp    dword ptr [ebx],0
  231. 015f  75 1d                         jne    017e
  232.                                 ;        NEARPLTe *p;
  233.                                 ;        p = &(nplt->near[0]);
  234. 0161  8d 7b 04                      lea    edi,4[ebx]
  235.                                 ;        p->next = NULL;
  236. 0164  c7 07 00000000                mov    dword ptr [edi],0
  237.                                 ;        p->used = YES;
  238. 016a  c6 47 04 01                   mov    byte ptr 4[edi],1
  239.                                 ;        p->plt = plt;
  240. 016e  8a 55 0c                      mov    dl,12[ebp]
  241. 0171  88 57 05                      mov    5[edi],dl
  242.                                 ;        p->dist = dist;
  243. 0174  89 47 06                      mov    6[edi],eax
  244.                                 ;        nplt->neartop = p;
  245. 0177  89 3b                         mov    [ebx],edi
  246. 0179  e9 000000c7                   jmp    0245
  247.                                 ;    } else {
  248. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 6
  249.  
  250. Addr  Object                    Source Program and Assembly Listing
  251.                                 ;        NEARPLTe *p1,*p2,*p;
  252.                                 ;        bool done;
  253.                                 ;        int i;
  254.                                 ;        done = NO;
  255. 017e                            .L017e:
  256. 017e  2b c0                         sub    eax,eax
  257. 0180  88 45 f3                      mov    -13[ebp],al
  258.                                 ;        for (p1=nplt->neartop,p2=NULL;  p1!=NULL;  p2=p1,p1=p1->next) {
  259. 0183  8b 55 fc                      mov    edx,-4[ebp]
  260. 0186  8b 3a                         mov    edi,[edx]
  261. 0188  89 45 f4                      mov    -12[ebp],eax
  262. 018b                            .L018b:
  263. 018b  23 ff                         and    edi,edi
  264. 018d  74 64                         je     01f3
  265.                                 ;            if (dist < p1->dist) {
  266. 018f  8b 45 f8                      mov    eax,-8[ebp]
  267. 0192  3b 47 06                      cmp    eax,6[edi]
  268. 0195  7d 55                         jnl    01ec
  269.                                 ;                done = YES;
  270. 0197  c6 45 f3 01                   mov    byte ptr -13[ebp],1
  271.                                 ;                for (i=0; i<16; i++)
  272. 019b  2b db                         sub    ebx,ebx
  273. 019d                            .L019d:
  274. 019d  83 fb 10                      cmp    ebx,16
  275. 01a0  7d 12                         jnl    01b4
  276.                                 ;                    if (! nplt->near[i].used)    break;
  277. 01a2  8d 04 9b                      lea    eax,[ebx+ebx*4]
  278. 01a5  03 c0                         add    eax,eax
  279. 01a7  8b 55 fc                      mov    edx,-4[ebp]
  280. 01aa  80 7c 02 08 00                cmp    byte ptr 8[edx+eax],0
  281. 01af  74 03                         je     01b4
  282. 01b1  43                            inc    ebx
  283. 01b2  eb e9                         jmp    019d
  284.                                 ;                if (i==16)
  285. 01b4                            .L01b4:
  286. 01b4  83 fb 10                      cmp    ebx,16
  287. 01b7  0f 84 00000088                je     0245
  288.                                 ;                    return;
  289.                                 ;                p = &(nplt->near[i]);
  290. 01bd  8d 04 9b                      lea    eax,[ebx+ebx*4]
  291. 01c0  03 c0                         add    eax,eax
  292. 01c2  8b 55 fc                      mov    edx,-4[ebp]
  293. 01c5  8d 74 02 04                   lea    esi,4[edx+eax]
  294.                                 ;                p->used = YES;
  295. 01c9  c6 46 04 01                   mov    byte ptr 4[esi],1
  296.                                 ;                p->next = p1;
  297. 01cd  89 3e                         mov    [esi],edi
  298.                                 ;                p->plt = plt;
  299. 01cf  8a 45 0c                      mov    al,12[ebp]
  300. 01d2  88 46 05                      mov    5[esi],al
  301.                                 ;                p->dist = dist;
  302. 01d5  8b 45 f8                      mov    eax,-8[ebp]
  303. 01d8  89 46 06                      mov    6[esi],eax
  304.                                 ;                if (p2 == NULL)
  305. 01db  83 7d f4 00                   cmp    dword ptr -12[ebp],0
  306. 01df  75 04                         jne    01e5
  307.                                 ;                    nplt->neartop = p;
  308. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 7
  309.  
  310. Addr  Object                    Source Program and Assembly Listing
  311. 01e1  89 32                         mov    [edx],esi
  312. 01e3  eb 0e                         jmp    01f3
  313.                                 ;                else
  314.                                 ;                    p2->next = p;
  315. 01e5                            .L01e5:
  316. 01e5  8b 45 f4                      mov    eax,-12[ebp]
  317. 01e8  89 30                         mov    [eax],esi
  318.                                 ;                break;
  319. 01ea  eb 07                         jmp    01f3
  320. 01ec                            .L01ec:
  321. 01ec  89 7d f4                      mov    -12[ebp],edi
  322. 01ef  8b 3f                         mov    edi,[edi]
  323. 01f1  eb 98                         jmp    018b
  324.                                 ;            }
  325.                                 ;        }
  326.                                 ;        if (!done) {
  327. 01f3                            .L01f3:
  328. 01f3  80 7d f3 00                   cmp    byte ptr -13[ebp],0
  329. 01f7  75 4c                         jne    0245
  330.                                 ;            for (i=0; i<16; i++)
  331. 01f9  2b db                         sub    ebx,ebx
  332. 01fb                            .L01fb:
  333. 01fb  83 fb 10                      cmp    ebx,16
  334. 01fe  7d 12                         jnl    0212
  335.                                 ;                if (! nplt->near[i].used)    break;
  336. 0200  8d 04 9b                      lea    eax,[ebx+ebx*4]
  337. 0203  03 c0                         add    eax,eax
  338. 0205  8b 55 fc                      mov    edx,-4[ebp]
  339. 0208  80 7c 02 08 00                cmp    byte ptr 8[edx+eax],0
  340. 020d  74 03                         je     0212
  341. 020f  43                            inc    ebx
  342. 0210  eb e9                         jmp    01fb
  343.                                 ;            if (i==16)
  344. 0212                            .L0212:
  345. 0212  83 fb 10                      cmp    ebx,16
  346. 0215  74 2e                         je     0245
  347.                                 ;                return;
  348.                                 ;            p = &(nplt->near[i]);
  349. 0217  8d 04 9b                      lea    eax,[ebx+ebx*4]
  350. 021a  03 c0                         add    eax,eax
  351. 021c  8b 55 fc                      mov    edx,-4[ebp]
  352. 021f  8d 74 02 04                   lea    esi,4[edx+eax]
  353.                                 ;            p->used = YES;
  354. 0223  c6 46 04 01                   mov    byte ptr 4[esi],1
  355.                                 ;            p->next = NULL;
  356. 0227  2b c0                         sub    eax,eax
  357. 0229  89 06                         mov    [esi],eax
  358.                                 ;            p->plt = plt;
  359. 022b  8a 4d 0c                      mov    cl,12[ebp]
  360. 022e  88 4e 05                      mov    5[esi],cl
  361.                                 ;            p->dist = dist;
  362. 0231  8b 4d f8                      mov    ecx,-8[ebp]
  363. 0234  89 4e 06                      mov    6[esi],ecx
  364.                                 ;            if (p2 == NULL)
  365. 0237  3b 45 f4                      cmp    eax,-12[ebp]
  366. 023a  75 04                         jne    0240
  367.                                 ;                nplt->neartop = p;
  368. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 8
  369.  
  370. Addr  Object                    Source Program and Assembly Listing
  371. 023c  89 32                         mov    [edx],esi
  372. 023e  eb 05                         jmp    0245
  373.                                 ;            else
  374.                                 ;                p2->next = p;
  375. 0240                            .L0240:
  376. 0240  8b 45 f4                      mov    eax,-12[ebp]
  377. 0243  89 30                         mov    [eax],esi
  378.                                 ;        }
  379.                                 ;    }
  380.                                 ;}
  381. 0245                            .L0245:
  382. 0245  5f                            pop    edi
  383. 0246  5e                            pop    esi
  384. 0247  5b                            pop    ebx
  385. 0248  c9                            leave
  386. 0249  c3                            rets
  387.                                 NEARPLT_ins    endp
  388. 024a  8bc0                          mod4   0
  389.                                 ;//     (local) 近似パレットリストの要素の削除
  390.                                 ;//-----------------------------------------------------------------------
  391.                                 ;static void NEARPLT_del(int grb, int plt)
  392. 024c                            .L024c:
  393.                                 NEARPLT_del    proc   near
  394. 024c  55                            push   ebp
  395. 024d  8b ec                         mov    ebp,esp
  396. 024f  56                            push   esi
  397. 0250  57                            push   edi
  398.                                 ;// [_GRBカラー grb に対する近似パレットリストの中から、
  399.                                 ;//   plt番のパレットの要素を削除する]
  400.                                 ;//          この関数は、リスト中に見つかった plt 番のパレット要素をすべて
  401.                                 ;//            削除する。また、リスト中に plt 番のパレット要素が存在しなくても
  402.                                 ;//            問題はない。
  403.                                 ;{
  404.                                 ;    NEARPLT *nplt;
  405.                                 ;    nplt = nearplt + grb;
  406. 0251  8b 45 08                      mov    eax,8[ebp]
  407. 0254  8d 04 85 00000000             lea    eax,[eax*4]
  408. 025b  8d 14 80                      lea    edx,[eax+eax*4]
  409. 025e  8d 14 d0                      lea    edx,[eax+edx*8]
  410. 0261  8b fa                         mov    edi,edx
  411. 0263  03 3d 00000000r               add    edi,@plt16
  412.                                 ;    NEARPLTe *p1,*p2;
  413.                                 ;    for (p1=nplt->neartop,p2=NULL;  p1!=NULL;  p2=p1,p1=p1->next) {
  414. 0269  8b 37                         mov    esi,[edi]
  415. 026b  2b c9                         sub    ecx,ecx
  416. 026d                            .L026d:
  417. 026d  23 f6                         and    esi,esi
  418. 026f  74 21                         je     0292
  419.                                 ;        if (p1->plt == plt) {
  420. 0271  0f b6 46 05                   movzbl eax,5[esi]
  421. 0275  3b 45 0c                      cmp    eax,12[ebp]
  422. 0278  75 12                         jne    028c
  423.                                 ;            if (p2==NULL)
  424. 027a  23 c9                         and    ecx,ecx
  425. 027c  75 06                         jne    0284
  426.                                 ;                nplt->neartop = p1->next;
  427. 027e  8b 06                         mov    eax,[esi]
  428. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 9
  429.  
  430. Addr  Object                    Source Program and Assembly Listing
  431. 0280  89 07                         mov    [edi],eax
  432. 0282  eb 04                         jmp    0288
  433.                                 ;            else
  434.                                 ;                p2->next = p1->next;
  435. 0284                            .L0284:
  436. 0284  8b 06                         mov    eax,[esi]
  437. 0286  89 01                         mov    [ecx],eax
  438.                                 ;            p1->used = NO;
  439. 0288                            .L0288:
  440. 0288  c6 46 04 00                   mov    byte ptr 4[esi],0
  441. 028c                            .L028c:
  442. 028c  8b ce                         mov    ecx,esi
  443. 028e  8b 36                         mov    esi,[esi]
  444. 0290  eb db                         jmp    026d
  445.                                 ;        }
  446.                                 ;    }
  447.                                 ;}
  448. 0292                            .L0292:
  449. 0292  5f                            pop    edi
  450. 0293  5e                            pop    esi
  451. 0294  c9                            leave
  452. 0295  c3                            rets
  453.                                 NEARPLT_del    endp
  454. 0296  8bc0                          mod4   0
  455.                                 ;//     (global) _GRB カラー 000 に対する近似パレットリストのダンプ出力
  456.                                 ;//                (デバッグ用関数)
  457.                                 ;//-----------------------------------------------------------------------
  458.                                 ;void __dumpNEARPLT0()
  459. 0298                            .L0298:
  460.                                     public    __dumpNEARPLT0
  461.                                 __dumpNEARPLT0    proc   near
  462. 0298  56                            push   esi
  463. 0299  57                            push   edi
  464.                                 ;{
  465.                                 ;    if (scrmode == 10)
  466. 029a  83 3d 00000000e 0a            cmp    dword ptr scrmode,10
  467. 02a1  74 6e                         je     0311
  468.                                 ;        return;
  469.                                 ;    int tc = 0*256+0*16+0;
  470. 02a3  2b ff                         sub    edi,edi
  471.                                 ;    sprintf(debugmsg,"nearplt[%03x] dump:",tc);
  472. 02a5  57                            push   edi
  473. 02a6  68 00000000r                  push   offset _mwLITERALS
  474. 02ab  68 00000000e                  push   offset debugmsg
  475. 02b0  e8 --------e                  call   sprintf
  476.                                 ;    msgout(debugmsg);
  477. 02b5  68 00000000e                  push   offset debugmsg
  478. 02ba  e8 --------e                  call   msgout
  479.                                 ;    NEARPLTe *p;
  480.                                 ;    p = (nearplt+tc)->neartop;
  481. 02bf  8d 04 bd 00000000             lea    eax,[edi*4]
  482. 02c6  8d 14 80                      lea    edx,[eax+eax*4]
  483. 02c9  8d 14 d0                      lea    edx,[eax+edx*8]
  484. 02cc  a1 00000000r                  mov    eax,@plt16
  485. 02d1  8b 34 10                      mov    esi,[eax+edx]
  486. 02d4  83 c4 10                      add    esp,16
  487.                                 ;    for ( ; p!=NULL; p=p->next) {
  488. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 10
  489.  
  490. Addr  Object                    Source Program and Assembly Listing
  491. 02d7                            .L02d7:
  492. 02d7  23 f6                         and    esi,esi
  493. 02d9  74 36                         je     0311
  494.                                 ;        sprintf(debugmsg, " %1x[%03x] d%4d", p->plt, plt16_get(p->plt), p->dist);
  495. 02db  ff 76 06                      push   dword ptr 6[esi]
  496. 02de  0f b6 46 05                   movzbl eax,5[esi]
  497. 02e2  50                            push   eax
  498. 02e3  e8 000000e8                   call   03d0
  499. 02e8  83 c4 04                      add    esp,4
  500. 02eb  50                            push   eax
  501. 02ec  0f b6 46 05                   movzbl eax,5[esi]
  502. 02f0  50                            push   eax
  503. 02f1  68 00000014r                  push   offset _mwLITERALS+20
  504. 02f6  68 00000000e                  push   offset debugmsg
  505. 02fb  e8 --------e                  call   sprintf
  506.                                 ;        msgout(debugmsg);
  507. 0300  68 00000000e                  push   offset debugmsg
  508. 0305  e8 --------e                  call   msgout
  509. 030a  8b 36                         mov    esi,[esi]
  510. 030c  83 c4 18                      add    esp,24
  511. 030f  eb c6                         jmp    02d7
  512.                                 ;    }
  513.                                 ;}
  514. 0311                            .L0311:
  515. 0311  5f                            pop    edi
  516. 0312  5e                            pop    esi
  517. 0313  c3                            rets
  518.                                 __dumpNEARPLT0    endp
  519. 0314                                mod4   0
  520.                                 ;//     (global) 近似パレットリストおよびこのモジュールの初期化
  521.                                 ;//-----------------------------------------------------------------------
  522.                                 ;int plt16_init()
  523. 0314                            .L0314:
  524.                                     public    plt16_init
  525.                                 plt16_init    proc   near
  526. 0314  56                            push   esi
  527. 0315  57                            push   edi
  528.                                 ;{
  529.                                 ;    int i,j;
  530.                                 ;    nearplt = calloc(sizeof(NEARPLT), 4096);
  531. 0316  68 00001000                   push   4096
  532. 031b  68 000000a4                   push   164
  533. 0320  e8 --------e                  call   calloc
  534. 0325  a3 00000000r                  mov    @plt16,eax
  535. 032a  83 c4 08                      add    esp,8
  536.                                 ;    if (nearplt == NULL)
  537. 032d  23 c0                         and    eax,eax
  538. 032f  75 07                         jne    0338
  539.                                 ;        return -1;
  540. 0331  b8 ffffffff                   mov    eax,-1
  541. 0336  eb 42                         jmp    037a
  542.                                 ;    for (i=0; i<16; i++)
  543. 0338                            .L0338:
  544. 0338  2b ff                         sub    edi,edi
  545. 033a                            .L033a:
  546. 033a  83 ff 10                      cmp    edi,16
  547. 033d  7d 13                         jnl    0352
  548. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 11
  549.  
  550. Addr  Object                    Source Program and Assembly Listing
  551.                                 ;        pltgrb[i] = _getplt(i);
  552. 033f  57                            push   edi
  553. 0340  e8 fffffcbb                   call   0000
  554. 0345  89 04 bd 00000004r            mov    @plt16+4[edi*4],eax
  555. 034c  47                            inc    edi
  556. 034d  83 c4 04                      add    esp,4
  557. 0350  eb e8                         jmp    033a
  558.                                 ;    for (i=0; i<4096; i++)
  559. 0352                            .L0352:
  560. 0352  2b ff                         sub    edi,edi
  561. 0354                            .L0354:
  562. 0354  81 ff 00001000                cmp    edi,4096
  563. 035a  7d 17                         jnl    0373
  564.                                 ;        for (j=0; j<16; j++)
  565. 035c  2b f6                         sub    esi,esi
  566. 035e                            .L035e:
  567. 035e  83 fe 10                      cmp    esi,16
  568. 0361  7d 0d                         jnl    0370
  569.                                 ;            NEARPLT_ins(i,j);
  570. 0363  56                            push   esi
  571. 0364  57                            push   edi
  572. 0365  e8 fffffdb6                   call   0120
  573. 036a  46                            inc    esi
  574. 036b  83 c4 08                      add    esp,8
  575. 036e  eb ee                         jmp    035e
  576. 0370                            .L0370:
  577. 0370  47                            inc    edi
  578. 0371  eb e1                         jmp    0354
  579.                                 ;    __dumpNEARPLT0();
  580. 0373                            .L0373:
  581. 0373  e8 ffffff20                   call   0298
  582.                                 ;    return 0;
  583. 0378  2b c0                         sub    eax,eax
  584.                                 ;}
  585. 037a                            .L037a:
  586. 037a  5f                            pop    edi
  587. 037b  5e                            pop    esi
  588. 037c  c3                            rets
  589.                                 plt16_init    endp
  590. 037d  668bc0                        mod4   0
  591.                                 ;//     (global) 指定したパレット番号に対するパレットの設定
  592.                                 ;//-----------------------------------------------------------------------
  593.                                 ;void    plt16_set(int plt, _GRB grb)
  594. 0380                            .L0380:
  595.                                     public    plt16_set
  596.                                 plt16_set    proc   near
  597. 0380  55                            push   ebp
  598. 0381  8b ec                         mov    ebp,esp
  599. 0383  53                            push   ebx
  600. 0384  56                            push   esi
  601. 0385  57                            push   edi
  602.                                 ;{
  603. 0386  8b 7d 08                      mov    edi,8[ebp]
  604. 0389  8b 75 0c                      mov    esi,12[ebp]
  605.                                 ;    int i;
  606.                                 ;    for (i=0; i<4096; i++)
  607. 038c  2b db                         sub    ebx,ebx
  608. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 12
  609.  
  610. Addr  Object                    Source Program and Assembly Listing
  611. 038e                            .L038e:
  612. 038e  81 fb 00001000                cmp    ebx,4096
  613. 0394  7d 0d                         jnl    03a3
  614.                                 ;        NEARPLT_del(i,plt);
  615. 0396  57                            push   edi
  616. 0397  53                            push   ebx
  617. 0398  e8 fffffeaf                   call   024c
  618. 039d  43                            inc    ebx
  619. 039e  83 c4 08                      add    esp,8
  620. 03a1  eb eb                         jmp    038e
  621.                                 ;    _setplt(plt, grb);
  622. 03a3                            .L03a3:
  623. 03a3  56                            push   esi
  624. 03a4  57                            push   edi
  625. 03a5  e8 fffffcaa                   call   0054
  626.                                 ;    pltgrb[plt] = grb;
  627. 03aa  89 34 bd 00000004r            mov    @plt16+4[edi*4],esi
  628.                                 ;    for (i=0; i<4096; i++)
  629. 03b1  2b db                         sub    ebx,ebx
  630. 03b3                            .L03b3:
  631. 03b3  83 c4 08                      add    esp,8
  632. 03b6  81 fb 00001000                cmp    ebx,4096
  633. 03bc  7d 0a                         jnl    03c8
  634.                                 ;        NEARPLT_ins(i,plt);
  635. 03be  57                            push   edi
  636. 03bf  53                            push   ebx
  637. 03c0  e8 fffffd5b                   call   0120
  638. 03c5  43                            inc    ebx
  639. 03c6  eb eb                         jmp    03b3
  640.                                 ;}
  641. 03c8                            .L03c8:
  642. 03c8  5f                            pop    edi
  643. 03c9  5e                            pop    esi
  644. 03ca  5b                            pop    ebx
  645. 03cb  c9                            leave
  646. 03cc  c3                            rets
  647.                                 plt16_set    endp
  648. 03cd  668bc0                        mod4   0
  649.                                 ;//     (global) 指定したパレット番号に対するパレット内容を得る
  650.                                 ;//-----------------------------------------------------------------------
  651.                                 ;_GRB    plt16_get(int plt)
  652. 03d0                            .L03d0:
  653.                                     public    plt16_get
  654.                                 plt16_get    proc   near
  655.                                 ;{
  656.                                 ;    return pltgrb[plt];
  657. 03d0  8b 44 24 04                   mov    eax,4[esp]
  658. 03d4  8b 04 85 00000004r            mov    eax,@plt16+4[eax*4]
  659.                                 ;}
  660. 03db  c3                            rets
  661.                                 plt16_get    endp
  662. 03dc                                mod4   0
  663.                                 ;//     (global) 指定した _GRB カラーの近似パレットを得る
  664.                                 ;//-----------------------------------------------------------------------
  665.                                 ;int        plt16_getnear(_GRB grb, int source_plt, int object_plt)
  666. 03dc                            .L03dc:
  667.                                     public    plt16_getnear
  668. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 13
  669.  
  670. Addr  Object                    Source Program and Assembly Listing
  671.                                 plt16_getnear    proc   near
  672. 03dc  55                            push   ebp
  673. 03dd  8b ec                         mov    ebp,esp
  674. 03df  50                            push   eax
  675. 03e0  53                            push   ebx
  676. 03e1  56                            push   esi
  677. 03e2  57                            push   edi
  678.                                 ;// 指定されたRGBカラーに最も近いパレットを返す
  679.                                 ;{
  680. 03e3  8b 7d 10                      mov    edi,16[ebp]
  681.                                 ;    NEARPLT *nplt;
  682.                                 ;    nplt = nearplt + grb;
  683. 03e6  8b 45 08                      mov    eax,8[ebp]
  684. 03e9  8d 04 85 00000000             lea    eax,[eax*4]
  685. 03f0  8d 14 80                      lea    edx,[eax+eax*4]
  686. 03f3  8d 14 d0                      lea    edx,[eax+edx*8]
  687. 03f6  03 15 00000000r               add    edx,@plt16
  688. 03fc  89 55 fc                      mov    -4[ebp],edx
  689.                                 ;    NEARPLTe *p;
  690.                                 ;    p = nplt->neartop;
  691. 03ff  8b 32                         mov    esi,[edx]
  692.                                 ;    if (p->plt != source_plt)
  693. 0401  0f b6 46 05                   movzbl eax,5[esi]
  694. 0405  3b 45 0c                      cmp    eax,12[ebp]
  695. 0408  75 5e                         jne    0468
  696.                                 ;        return p->plt;
  697.                                 ;    else {    // 「一番近い色」がもとの色と同じ色の場合
  698.                                 ;        int distmax = (nearplt+pltgrb[p->plt])->near[object_plt].dist;
  699. 040a  0f b6 46 05                   movzbl eax,5[esi]
  700. 040e  8b 04 85 00000004r            mov    eax,@plt16+4[eax*4]
  701. 0415  8d 04 85 00000000             lea    eax,[eax*4]
  702. 041c  8d 14 80                      lea    edx,[eax+eax*4]
  703. 041f  8d 14 d0                      lea    edx,[eax+edx*8]
  704. 0422  8d 04 bf                      lea    eax,[edi+edi*4]
  705. 0425  03 c0                         add    eax,eax
  706. 0427  03 c2                         add    eax,edx
  707. 0429  8b 15 00000000r               mov    edx,@plt16
  708. 042f  8b 5c 02 0a                   mov    ebx,10[edx+eax]
  709.                                 ;        // distmax = _min(distmax, _coldiff(pltgrb[source_plt], pltgrb[object_plt]));
  710.                                 ;        for (p=p->next;  p!=NULL;  p=p->next) {
  711. 0433                            .L0433:
  712. 0433  8b 36                         mov    esi,[esi]
  713. 0435  23 f6                         and    esi,esi
  714. 0437  74 2d                         je     0466
  715.                                 ;            if ((nearplt+pltgrb[p->plt])->near[object_plt].dist <= distmax)
  716. 0439  0f b6 46 05                   movzbl eax,5[esi]
  717. 043d  8b 14 85 00000004r            mov    edx,@plt16+4[eax*4]
  718. 0444  8d 14 95 00000000             lea    edx,[edx*4]
  719. 044b  8d 0c 92                      lea    ecx,[edx+edx*4]
  720. 044e  8d 0c ca                      lea    ecx,[edx+ecx*8]
  721. 0451  8d 14 bf                      lea    edx,[edi+edi*4]
  722. 0454  03 d2                         add    edx,edx
  723. 0456  03 d1                         add    edx,ecx
  724. 0458  8b 0d 00000000r               mov    ecx,@plt16
  725. 045e  3b 5c 11 0a                   cmp    ebx,10[ecx+edx]
  726. 0462  7d 04                         jnl    0468
  727.                                 ;                return p->plt;
  728. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 14
  729.  
  730. Addr  Object                    Source Program and Assembly Listing
  731. 0464  eb cd                         jmp    0433
  732.                                 ;        }
  733.                                 ;        return object_plt;
  734. 0466                            .L0466:
  735. 0466  8b c7                         mov    eax,edi
  736.                                 ;    }
  737.                                 ;}
  738. 0468                            .L0468:
  739. 0468  5f                            pop    edi
  740. 0469  5e                            pop    esi
  741. 046a  5b                            pop    ebx
  742. 046b  c9                            leave
  743. 046c  c3                            rets
  744.                                 plt16_getnear    endp
  745. 046d  668bc0                        mod4   0
  746.                                 ;//     (global) 指定した2つの _GRB カラーを混ぜ合わせる
  747.                                 ;//-----------------------------------------------------------------------
  748.                                 ;_GRB    plt16_gray(_GRB grb1, _GRB grb2, int gray)
  749. 0470                            .L0470:
  750.                                     public    plt16_gray
  751.                                 plt16_gray    proc   near
  752. 0470  55                            push   ebp
  753. 0471  8b ec                         mov    ebp,esp
  754. 0473  83 ec 24                      sub    esp,36
  755. 0476  53                            push   ebx
  756. 0477  56                            push   esi
  757. 0478  57                            push   edi
  758.                                 ;// gray : 0..256(grb2の「強さ」)
  759.                                 ;{
  760. 0479  8b 7d 08                      mov    edi,8[ebp]
  761. 047c  8b 75 10                      mov    esi,16[ebp]
  762.                                 ;    if (gray == 0)
  763. 047f  23 f6                         and    esi,esi
  764. 0481  75 07                         jne    048a
  765.                                 ;        return grb1;
  766. 0483  8b c7                         mov    eax,edi
  767. 0485  e9 000000e2                   jmp    056c
  768.                                 ;    else if (gray == 256)
  769. 048a                            .L048a:
  770. 048a  81 fe 00000100                cmp    esi,256
  771. 0490  75 08                         jne    049a
  772.                                 ;        return grb2;
  773. 0492  8b 45 0c                      mov    eax,12[ebp]
  774. 0495  e9 000000d2                   jmp    056c
  775.                                 ;    else {
  776.                                 ;        gray = _min(256,_max(gray,0));
  777. 049a                            .L049a:
  778. 049a  2b c0                         sub    eax,eax
  779. 049c  3b c6                         cmp    eax,esi
  780. 049e  7c 01                         jl     04a1
  781. 04a0  96                            xchg   eax,esi
  782. 04a1                            .L04a1:
  783. 04a1  b8 00000100                   mov    eax,256
  784. 04a6  3b f0                         cmp    esi,eax
  785. 04a8  7c 02                         jl     04ac
  786. 04aa  8b f0                         mov    esi,eax
  787.                                 ;        int gg,r1,r2,g1,g2,b1,b2,r,g,b;
  788. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 15
  789.  
  790. Addr  Object                    Source Program and Assembly Listing
  791.                                 ;        gg = 256-gray;
  792. 04ac                            .L04ac:
  793. 04ac  8b d8                         mov    ebx,eax
  794. 04ae  2b de                         sub    ebx,esi
  795.                                 ;        g1 = (grb1>>8)&15;
  796. 04b0  8b d7                         mov    edx,edi
  797. 04b2  c1 fa 08                      sar    edx,8
  798. 04b5  81 e2 0000000f                and    edx,15
  799. 04bb  89 55 f4                      mov    -12[ebp],edx
  800.                                 ;        r1 = (grb1>>4)&15;
  801. 04be  8b c7                         mov    eax,edi
  802. 04c0  c1 f8 04                      sar    eax,4
  803. 04c3  25 0000000f                   and    eax,15
  804. 04c8  89 45 fc                      mov    -4[ebp],eax
  805.                                 ;        b1 =  grb1 & 15;
  806. 04cb  8b cf                         mov    ecx,edi
  807. 04cd  81 e1 0000000f                and    ecx,15
  808. 04d3  89 4d ec                      mov    -20[ebp],ecx
  809.                                 ;        g2 = (grb2>>8)&15;
  810. 04d6  8b 45 0c                      mov    eax,12[ebp]
  811. 04d9  c1 f8 08                      sar    eax,8
  812. 04dc  25 0000000f                   and    eax,15
  813. 04e1  89 45 f0                      mov    -16[ebp],eax
  814.                                 ;        r2 = (grb2>>4)&15;
  815. 04e4  8b 45 0c                      mov    eax,12[ebp]
  816. 04e7  c1 f8 04                      sar    eax,4
  817. 04ea  25 0000000f                   and    eax,15
  818. 04ef  89 45 f8                      mov    -8[ebp],eax
  819.                                 ;        b2 =  grb2 & 15;
  820. 04f2  8b 45 0c                      mov    eax,12[ebp]
  821. 04f5  25 0000000f                   and    eax,15
  822. 04fa  89 45 e8                      mov    -24[ebp],eax
  823.                                 ;        g = (gg*g1 + gray*g2 + 128) / 256;
  824. 04fd  0f af d3                      imul   edx,ebx
  825. 0500  8b c6                         mov    eax,esi
  826. 0502  0f af 45 f0                   imul   eax,-16[ebp]
  827. 0506  03 c2                         add    eax,edx
  828. 0508  05 00000080                   add    eax,128
  829. 050d  99                            cwd
  830. 050e  b9 00000100                   mov    ecx,256
  831. 0513  f7 f9                         idiv   ecx
  832. 0515  89 45 e0                      mov    -32[ebp],eax
  833.                                 ;        r = (gg*r1 + gray*r2 + 128) / 256;
  834. 0518  8b d3                         mov    edx,ebx
  835. 051a  0f af 55 fc                   imul   edx,-4[ebp]
  836. 051e  8b ce                         mov    ecx,esi
  837. 0520  0f af 4d f8                   imul   ecx,-8[ebp]
  838. 0524  03 ca                         add    ecx,edx
  839. 0526  81 c1 00000080                add    ecx,128
  840. 052c  91                            xchg   eax,ecx
  841. 052d  99                            cwd
  842. 052e  b9 00000100                   mov    ecx,256
  843. 0533  f7 f9                         idiv   ecx
  844. 0535  89 45 e4                      mov    -28[ebp],eax
  845.                                 ;        b = (gg*b1 + gray*b2 + 128) / 256;
  846. 0538  8b d3                         mov    edx,ebx
  847. 053a  0f af 55 ec                   imul   edx,-20[ebp]
  848. MetaWare High C Compiler 1.7  22-Dec-92 09:16:10   plt16.c            Page 16
  849.  
  850. Addr  Object                    Source Program and Assembly Listing
  851. 053e  8b ce                         mov    ecx,esi
  852. 0540  0f af 4d e8                   imul   ecx,-24[ebp]
  853. 0544  03 ca                         add    ecx,edx
  854. 0546  81 c1 00000080                add    ecx,128
  855. 054c  91                            xchg   eax,ecx
  856. 054d  99                            cwd
  857. 054e  b9 00000100                   mov    ecx,256
  858. 0553  f7 f9                         idiv   ecx
  859. 0555  89 45 dc                      mov    -36[ebp],eax
  860.                                 ;        return (g<<8)|(r<<4)|b;
  861. 0558  8b 55 e0                      mov    edx,-32[ebp]
  862. 055b  c1 e2 08                      shl    edx,8
  863. 055e  8b 45 e4                      mov    eax,-28[ebp]
  864. 0561  c1 e0 04                      shl    eax,4
  865. 0564  0b c2                         or     eax,edx
  866. 0566  8b 55 dc                      mov    edx,-36[ebp]
  867. 0569  0b d0                         or     edx,eax
  868. 056b  92                            xchg   eax,edx
  869.                                 ;    }
  870.                                 ;}
  871. 056c                            .L056c:
  872. 056c  5f                            pop    edi
  873. 056d  5e                            pop    esi
  874. 056e  5b                            pop    ebx
  875. 056f  c9                            leave
  876. 0570  c3                            rets
  877.                                 plt16_gray    endp
  878.                                 plt16    ends
  879.                                 _mwLITERALS    segment public 'DATA'
  880. 0000  6e656172706c745b25303378      db      'nearplt[%03x'
  881. 000c  5d2064756d703a                db      '] dump:'
  882. 0013  00                            db    0
  883. 0014  202531785b253033785d2064      db      ' %1x[%03x] d'
  884. 0020  253464                        db      '%4d'
  885. 0023  00                            db    0
  886. 0024                            _mwLITERALS    ends
  887.                                 ;/* end of plt16.c */
  888. No user errors   No warnings
  889. End of processing, 22-Dec-92 09:16:23              plt16.c
  890.